package com.kgc.sportscircle.controller;

import com.kgc.sportscircle.pojo.Newsinternationalfoot;
import com.kgc.sportscircle.service.NewsinternationalfootService;
import com.kgc.sportscircle.utils.Page;
import com.kgc.sportscircle.vo.NewsinternationalfootParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 描述： 控制器
* @author 杨海文
* @date 2019/07/22
*/
@RestController
@RequestMapping("/newsinternationalfoot")
public class NewsinternationalfootController{
	@Reference(version ="1.11")
	private NewsinternationalfootService newsinternationalfootService;
 	
 	@RequestMapping("/findById.json")
    public Newsinternationalfoot findById(Integer id){
        Newsinternationalfoot result = null;
        try {
            result = newsinternationalfootService.findById(id);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：获取所有的Newsinternationalfoot对象
     */
    @RequestMapping("/findAll.json")
    public List<Newsinternationalfoot> findAll(){
        List<Newsinternationalfoot> result = null;
        try {
            result = newsinternationalfootService.findAll();
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：新增保存Newsinternationalfoot对象
     */
    @RequestMapping("/save.json")
    public Map save(Newsinternationalfoot newsinternationalfoot){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存失败");
        try {
            if(newsinternationalfootService.save(newsinternationalfoot)>0){
                result.put("flag",true);
                result.put("msg","保存成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：根据主键删除对象
     * @param id
     */
    @RequestMapping("/delete.json")
    public Map delete(Integer id){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存失败");
        try {
            if(newsinternationalfootService.delete(id)>0){
                result.put("flag",true);
                result.put("msg","保存成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：更新对象
     */
    @RequestMapping("/update.json")
    public Map update(Newsinternationalfoot newsinternationalfoot){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","更新失败");
        try {
            if( newsinternationalfootService.update(newsinternationalfoot)>0){
                result.put("flag",true);
                result.put("msg","更新成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;

    }

    /**
     * 根据不确定的条件，动态查询
     */
    @RequestMapping("/query.json")
    public List<Newsinternationalfoot> query(NewsinternationalfootParam param){
        List<Newsinternationalfoot> result = null;
        try {
            result = newsinternationalfootService.query(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 根据不确定的条件，动态分页查询
     */
    @RequestMapping("/queryByPage.json")
    public Page queryByPage(NewsinternationalfootParam param){
        Page result = null;
        try {
            result = newsinternationalfootService.queryByPage(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
 }
